package school.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import school.domain.Comment;
import school.mapper.CommentMapper;
import school.support.BaseController;

@Controller
@RequestMapping("comment")
public class CommentController extends BaseController {

    @Autowired
    private CommentMapper commentMapper;

    /**
     * 发布评论
     * @param comment
     * @return
     */
    @RequestMapping("send")
    public String send(Comment comment){
        if (isLogin()) {
            comment.setUserid(loginUser().getId());
            commentMapper.insert(comment);
            return refresh();
        }
        return "redirect:/login.do";
    }
}
